<template>
  <div class='container'>
    <el-dialog
      title="题目审核"
      :visible="checkdialogVisible"
      width="30%"
      @close="close">
      <el-form>
        <el-form-item>
           <el-radio-group v-model="checkData.chkState">
            <el-radio  label="1">通过</el-radio>
            <el-radio  label="2">拒绝</el-radio>
          </el-radio-group>

        </el-form-item>
        <el-form-item>
          <el-input type="textarea" style="margin-top:15px" placeholder="请输入审核意见" v-model="checkData.chkRemarks"></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  props: {
    checkdialogVisible: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      checkData: {
        id: null,
        chkState: '',
        chkRemarks: null
      }
    }
  },
  methods: {
    // 关闭对话框
    close () {
      this.$emit('update:checkdialogVisible', false)
      this.checkData = {
        id: null,
        chkState: '',
        chkRemarks: null
      }
    },

    // 确定按钮发送请求
    async confirm () {
      if (!this.checkData.chkRemarks) return this.$message.error('请输入审核意见')
      console.log(this.data.id)
      await choiceCheck({ ...this.checkData, id: this.data.id, chkState: +this.checkData.chkState })
      // console.log(data)
      this.$message.success('操作成功')
      this.close()
      this.$emit('uploadlist')
    }
  }
}
</script>

<style scoped lang='less'></style>
